﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x020001CF RID: 463
public class CutSceneEdit_Command : MonoBehaviour
{
	// Token: 0x17000166 RID: 358
	// (get) Token: 0x06000BFD RID: 3069 RVA: 0x00045C08 File Offset: 0x00043E08
	// (set) Token: 0x06000BFE RID: 3070 RVA: 0x00045C10 File Offset: 0x00043E10
	public int ActiveCommandNo { get; private set; }

	// Token: 0x17000167 RID: 359
	// (get) Token: 0x06000BFF RID: 3071 RVA: 0x00045C1C File Offset: 0x00043E1C
	// (set) Token: 0x06000C00 RID: 3072 RVA: 0x00045C24 File Offset: 0x00043E24
	public float SelectTime { get; private set; }

	// Token: 0x06000C01 RID: 3073 RVA: 0x00045C30 File Offset: 0x00043E30
	private void Awake()
	{
		this.cutActEdits[1] = base.GetComponentInChildren<CutActionEdit_ColorFilter>(true);
		this.cutActEdits[5] = base.GetComponentInChildren<CutActionEdit_Voice>(true);
		this.cutActEdits[6] = base.GetComponentInChildren<CutActionEdit_SubTitle>(true);
		this.cutActEdits[7] = base.GetComponentInChildren<CutActionEdit_Anime>(true);
		this.cutActEdits[9] = base.GetComponentInChildren<CutActionEdit_Camera>(true);
		this.addCommandDropdown.ClearOptions();
		for (int i = 0; i < 17; i++)
		{
			this.addCommandDropdown.options.Add(new Dropdown.OptionData(CutSceneEdit_Command.CutActNames[i]));
		}
		this.addCommandDropdown.value = -1;
		this.ActiveCommandNo = -1;
		this.SelectTime = -1f;
	}

	// Token: 0x06000C02 RID: 3074 RVA: 0x00045CE4 File Offset: 0x00043EE4
	public void SetList(float time)
	{
		this.SelectTime = time;
		this.selActs.Clear();
		foreach (CutAction cutAction in this.edit.cutScene.Actions)
		{
			if (cutAction.time == time)
			{
				this.selActs.Add(cutAction);
			}
		}
		for (int i = 0; i < this.cmndTgls.Count; i++)
		{
			UnityEngine.Object.Destroy(this.cmndTgls[i].gameObject);
		}
		this.cmndTgls.Clear();
		foreach (CutAction cutAction2 in this.selActs)
		{
			Toggle toggle = UnityEngine.Object.Instantiate<Toggle>(this.commandOriginal);
			toggle.gameObject.SetActive(true);
			Text componentInChildren = toggle.GetComponentInChildren<Text>();
			componentInChildren.text = CutSceneEdit_Command.CutActNames[(int)cutAction2.Type];
			toggle.transform.SetParent(this.commandsParent);
			this.cmndTgls.Add(toggle);
		}
		this.ActiveCommandNo = -1;
		this.Select(true);
		this.timeText.text = time.ToString("000.00");
	}

	// Token: 0x06000C03 RID: 3075 RVA: 0x00045E6C File Offset: 0x0004406C
	public void ClearList()
	{
		this.selActs.Clear();
		for (int i = 0; i < this.cmndTgls.Count; i++)
		{
			UnityEngine.Object.Destroy(this.cmndTgls[i].gameObject);
		}
		this.cmndTgls.Clear();
		this.AllEditClose();
	}

	// Token: 0x06000C04 RID: 3076 RVA: 0x00045EC8 File Offset: 0x000440C8
	private void Update()
	{
		if (this.selActs.Count == 0)
		{
			return;
		}
		this.Select(false);
	}

	// Token: 0x06000C05 RID: 3077 RVA: 0x00045EE4 File Offset: 0x000440E4
	private void Select(bool forceUpdate)
	{
		int num = -1;
		for (int i = 0; i < this.cmndTgls.Count; i++)
		{
			if (this.cmndTgls[i].isOn)
			{
				num = i;
				break;
			}
		}
		if (this.ActiveCommandNo != num || forceUpdate)
		{
			this.ActiveCommandNo = num;
			CUTACT cutact = CUTACT.UNKNOWN;
			if (this.ActiveCommandNo != -1)
			{
				cutact = this.selActs[this.ActiveCommandNo].Type;
			}
			for (int j = 0; j < 17; j++)
			{
				if (!(this.cutActEdits[j] == null))
				{
					if (j == (int)cutact)
					{
						this.cutActEdits[j].gameObject.SetActive(true);
						this.cutActEdits[j].Setup(this.selActs[this.ActiveCommandNo]);
					}
					else
					{
						this.cutActEdits[j].gameObject.SetActive(false);
					}
				}
			}
		}
	}

	// Token: 0x06000C06 RID: 3078 RVA: 0x00045FE8 File Offset: 0x000441E8
	private void AllEditClose()
	{
		for (int i = 0; i < 17; i++)
		{
			if (this.cutActEdits[i])
			{
				this.cutActEdits[i].gameObject.SetActive(false);
			}
		}
	}

	// Token: 0x06000C07 RID: 3079 RVA: 0x00046030 File Offset: 0x00044230
	public void AddCommand()
	{
		float nowTime = this.edit.timeBar.nowTime;
		CUTACT value = (CUTACT)this.addCommandDropdown.value;
		this.edit.cutScene.AddAction(value, nowTime);
		this.edit.timeBar.ReputKeys(true);
		this.edit.timeBar.SetNowTime(nowTime);
	}

	// Token: 0x06000C08 RID: 3080 RVA: 0x00046090 File Offset: 0x00044290
	public void DeleteCommand()
	{
		this.edit.cutScene.DeleteAction(this.selActs[this.ActiveCommandNo]);
		this.ActiveCommandNo = -1;
		this.ClearList();
		this.edit.timeBar.ReputKeys(true);
		this.AllEditClose();
		this.SetList(this.SelectTime);
	}

	// Token: 0x04000C2C RID: 3116
	public CutSceneEdit edit;

	// Token: 0x04000C2D RID: 3117
	[SerializeField]
	private Toggle commandOriginal;

	// Token: 0x04000C2E RID: 3118
	[SerializeField]
	private RectTransform commandsParent;

	// Token: 0x04000C2F RID: 3119
	[SerializeField]
	private Dropdown addCommandDropdown;

	// Token: 0x04000C30 RID: 3120
	[SerializeField]
	private Text timeText;

	// Token: 0x04000C31 RID: 3121
	private CutActionEdit[] cutActEdits = new CutActionEdit[17];

	// Token: 0x04000C32 RID: 3122
	private List<CutAction> selActs = new List<CutAction>();

	// Token: 0x04000C33 RID: 3123
	private List<Toggle> cmndTgls = new List<Toggle>();

	// Token: 0x04000C36 RID: 3126
	private static readonly string[] CutActNames = new string[]
	{
		"スクリプトジャンプ",
		"カラーフィルター",
		"イメージ",
		"BGM",
		"SE",
		"音声",
		"字幕",
		"アニメ",
		"表情",
		"カメラ",
		"位置",
		"キャラ表示",
		"IK",
		"ライト",
		"次のシーン",
		"回想終了",
		"ゲーム変数"
	};
}
